Skip to content

Validate that submitted cards actually form a Set#186

Open
adotdong29 wants to merge 1 commit into
ekzhang:mainfrom
adotdong29:fix/validate-set
Open

Validate that submitted cards actually form a Set#186
adotdong29 wants to merge 1 commit into
ekzhang:mainfrom
adotdong29:fix/validate-set

Conversation

@adotdong29

@adotdong29 adotdong29 commented May 1, 2026

Copy link
Copy Markdown

hello! I am an avid set enjoyer, and enjoy the game setwithfriends, which helps me connect with my friends too! I noticed this issue when I was playing and thought I could try to help out a game I love! I appreciate any feedback or criticism you have!

Bug

Event handlers in src/util.js and functions/src/game.ts only check that submitted cards are distinct and on the board. They don't check that the cards actually form a Set. So a player can submit any three on-board cards (e.g. 0000, 0001, 0010, where attribute 2 sums to 1 mod 3) and get credit for a Set, inflating their score and Elo.

The server-side gap is the load-bearing one: a player can POST directly to gameData/<id>/events without going through the client.

Fix

Adds checkSet(c1, c2, c3) (and checkSetUltra for ultraset mode) to:

  • processEventNormal, processEventChain, processEventUltra in src/util.js
  • replayEventNormal, replayEventChain, replayEventUltra in functions/src/game.ts

Both sides need it: client to keep the local UI honest, server to keep the database honest.

Tests

Added 6 tests in src/util.test.js covering normal, set-chain, and ultraset modes. Each verifies that non-Set submissions leave history empty and score at zero, and that real Sets still register. All 14 tests in the file pass.

Event handlers checked that cards were distinct and on the board, but
never verified they form a Set. Any three distinct on-board cards could
be submitted and counted as a Set, inflating scores and Elo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant